feat(react-router): Add Experimental React Server Components (RSC) instrumentation#18882
feat(react-router): Add Experimental React Server Components (RSC) instrumentation#18882onurtemizkan wants to merge 13 commits intodevelopfrom
Conversation
node-overhead report 🧳Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
|
159fb80 to
07fc2d6
Compare
|
@onurtemizkan sorry this one went under the radar. Can you resolve the conflict and ping me again? |
07fc2d6 to
c94138a
Compare
|
@chargome, it's ready for review 👍 |
Codecov Results 📊Generated by Codecov Action |
chargome
left a comment
There was a problem hiding this comment.
Generally LGTM to me but is there a way we could already wrap the server components with vite? Also initing the Client in a hook might happen quite late – any ideas if the client will eventually support an entry file?
| /** | ||
| * WeakSet to track errors that have been captured to avoid double-capture. | ||
| * Uses WeakSet so errors are automatically removed when garbage collected. | ||
| */ | ||
| const CAPTURED_ERRORS = new WeakSet<object>(); |
There was a problem hiding this comment.
q: Why do we need this in here? We have a dedupe integration that should take of this I think?
| export { wrapServerFunction } from './wrapServerFunction'; | ||
| export { wrapServerComponent } from './wrapServerComponent'; | ||
|
|
||
| export type { ServerComponentContext, WrapServerFunctionOptions } from './types'; |
There was a problem hiding this comment.
RSC request handler wrappers not exported from package
Medium Severity
The PR description documents wrapMatchRSCServerRequest, wrapRouteRSCServerRequest, and wrapServerFunctions as public APIs with usage examples showing imports from @sentry/react-router. However, these functions are implemented in their respective files but not exported from packages/react-router/src/server/rsc/index.ts. Only wrapServerFunction and wrapServerComponent are exported. Users following the documentation will get import errors when trying to use the RSC request handler wrappers.
Additional Locations (1)
packages/react-router/src/server/rsc/wrapMatchRSCServerRequest.ts
Outdated
Show resolved
Hide resolved
…lag in RSC wrappers
7954e55 to
141002a
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| } catch { | ||
| return false; | ||
| } | ||
| } |
There was a problem hiding this comment.
Redundant isAlreadyCaptured duplicates captureException internal dedup
Low Severity
The isAlreadyCaptured function in responseUtils.ts duplicates dedup logic already internal to captureException. The core SDK's captureException calls checkOrSetAlreadyCaught (in packages/core/src/client.ts), which checks __sentry_captured__ and returns early if the error was already captured. This makes the pre-check in wrapServerComponent and wrapServerFunction redundant and introduces a maintenance risk if the core SDK's property name or logic changes. The PR reviewer @chargome also flagged this.
Additional Locations (1)
| } | ||
| return false; | ||
| }, | ||
| }); |
There was a problem hiding this comment.
Auto-instrumentation silently drops export * re-exports
Medium Severity
The recast.visit call in analyzeModule handles visitExportDefaultDeclaration and visitExportNamedDeclaration but has no visitExportAllDeclaration handler. When a "use server" file uses export * from './other-actions' alongside direct exports, the transform hook completely replaces the file content with generated wrapper code that only includes the directly declared exports. The export * re-exports are silently dropped, causing those functions to become unavailable at runtime.


Resolves: #17337
Adds experimental instrumentation for React Router v7.9.0+ React Server Components (RSC).
React Router's RSC support is currently behind
unstable_reactRouterRSC()and subject to change. These wrappers provide error capture and performance tracing for RSC server requests, server components, and server functions.RSC Request Handlers
Added
wrapMatchRSCServerRequest()andwrapRouteRSCServerRequest():wrapMatchRSCServerRequest- Wraps RSC server matching with spans for generateResponse and loadServerActionwrapRouteRSCServerRequest- Wraps SSR request handling with spans for fetchServer and renderHTMLServer Components
Added
wrapServerComponent()for error instrumentation:Redirect (3xx) and not-found (404) responses are not captured as errors.
Server Functions
Added
wrapServerFunction()andwrapServerFunctions()for "use server" functions:Needs docs PR